//
//  OtherH5ViewController.m
//  B2C
//
//  Created by 李小龙 on 2017/8/1.
//  Copyright © 2017年 lixiaolong. All rights reserved.
//

#import "OtherH5ViewController.h"

@interface OtherH5ViewController ()<UIWebViewDelegate>
@property (weak, nonatomic) IBOutlet UIWebView *webView;

@end

@implementation OtherH5ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [self getNetData];
}
- (void)getNetData {
    [MBProgressHUD showHUDProgress:self.view animated:YES];
    //    [self startLoadingGifView];
    __weak typeof(self) weakSelf = self;
    [MYAFNetworking POST:URL_Get_Colums parameters:@{@"cid":@(self.type)} success:^(NSURLSessionDataTask *task, id responseObject) {
        if ([responseObject[@"code"] isEqualToString:@"200"]) {
            weakSelf.url = responseObject[@"data"][@"ccontent"];
            [weakSelf.webView loadRequest:[NSURLRequest requestWithURL:GetUrl(weakSelf.url)]];
        } else {
            [MBProgressHUD hideHUDForView:self.view animated:YES];
            //            [weakSelf stopLoadingGifView];
            [MBProgressHUD showError:weakSelf.view title:responseObject[@"message"] code:responseObject[@"code"] animated:YES];
        }
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError *error) {
        [MBProgressHUD hideHUDForView:self.view animated:YES];
        //        [weakSelf stopLoadingGifView];
        [MBProgressHUD showError:weakSelf.view title:@"" code:@"" animated:YES];
    }];
}
#pragma mark - webViewDelegate
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
//    [MBProgressHUD showHUDProgress:self.view animated:YES];
    return YES;
}
- (void)webViewDidFinishLoad:(UIWebView *)webView {
    [MBProgressHUD hideHUDForView:self.view animated:YES];
}
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
    [MBProgressHUD hideHUDForView:self.view animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
